﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Krist_em_up.Characters;
using Microsoft.Xna.Framework;
using Krist_em_up.Item.Projectiles;

namespace Krist_em_up.Item.Weapons
{
    class AutomaticGun : Gun
    {
        public AutomaticGun(int owner, Kristemup k)
            : base(owner, k)
        {
            this.Name = "Automatic Gun";
            this.reloadTimer = new TimeSpan(0,0,0,0,150);
            this.Ammunition = 50;
        }

        /// <summary>
        /// Pull the trigger nigga!
        /// </summary>
        /// <param name="position">Position where the weapon shoot</param>
        /// <param name="direction">True for right, false for left</param>
        public override void Shoot(Vector2 position, bool direction)
        {
            if (reloadTimer <= TimeSpan.Zero)
            {
                try
                {
                    Ammunition--;
                    GunBullet balle;
                    if (direction)
                        balle = new GunBullet(owner, game, new Vector2(position.X + Kris.WIDTH, position.Y + Kris.HEIGHT / 2 + 10), new Vector2(1, 0));
                    else
                        balle = new GunBullet(owner, game, new Vector2(position.X, position.Y + Kris.HEIGHT / 2 + 10), new Vector2(-1, 0));
                    game.bullets.Add(balle);
                }
                catch (NoAmmoException) { }
                this.reloadTimer = new TimeSpan(0, 0, 0, 0, 150);
            }
        }
    }
}
